<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<div id="app">
    <button @click="showc">显示仓库的内容</button>
    <h1>{{this.$store.state.count}}</h1>
    <button @click="add">加1</button>
</div>

<script src="node_modules/vue/dist/vue.js"></script>
<script src="node_modules/vuex/dist/vuex.js"></script>

<script>

    let store = new Vuex.Store({
        state:{
            count:567
        },
        mutations:{
            //{payload}  {}的作用是解构对象
            increate:function(state,{payload}){
                // console.log(payload)  //{count:3}
                state.count += payload.count;
            }
        }
    })

    var vm = new Vue({
        el:"#app",
        data:{
            count:0
        },
        store,//
        methods: {
            showc:function(){
                console.log(this.$store);
            },
            add:function(){
                this.$store.commit({
                    type:"increate",
                    payload:{
                        count:3,
                    }
                });
            },
        }
    })
</script>

</body>
</html>